﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core.Utils;

namespace Cofe.Web.Utils
{
    public static class WebUserRoleUtils
    {
        public static string UserRoles = "Admin, Me, FamilyMember, Friend";

        public static WebUserRole[] PossibleRoles
        {
            get
            {
                return new WebUserRole[] { WebUserRole.Admin, WebUserRole.Me, WebUserRole.FamilyMember, WebUserRole.Friend, WebUserRole.Other };
            }
        }

        public static string GetRoleString(this WebUserRole role)
        {
            return EnumUtils.GetPropertyName(role);            
        }

        public static WebUserRole GetRole(string roleString)
        {
            WebUserRole retVal;
            if (EnumUtils<WebUserRole>.EnumTryParse(roleString, out retVal))
                return retVal;
            return WebUserRole.Other;
        }
    }
}
